﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace PickGold.Callers
{
	/// <summary>
	/// Remote Procedure Call
	/// </summary>
	public interface IRemoteProcedureCall
	{
		/// <summary>
		/// 开始一个默认的异步委托调用
		/// </summary>
		/// <param name="handler">异步调用委托</param>
		/// <param name="callback">异步调用完成委托</param>
		/// <returns>异步操作状态</returns>
		IAsyncResult BeginInvoke<TYPE>(IDelegate<TYPE> handler, AsyncCallback callback);
		/// <summary>
		/// 开始一个默认的异步委托调用
		/// </summary>
		/// <param name="handler">异步调用委托</param>
		/// <param name="callback">异步调用完成委托</param>
		/// <param name="object">自定义操作状态</param>
		/// <returns>异步操作状态</returns>
		IAsyncResult BeginInvoke<TYPE>(IDelegate<TYPE> handler, AsyncCallback callback, object @object);
		/// <summary>
		/// 导步委托调用结束
		/// </summary>
		/// <param name="asyncResult">异步操作状态</param>
		/// <param name="result">异步操作结果</param>
		/// <returns>调用异常，如果成功则返回空</returns>
		Exception EndInvoke<TYPE>(IAsyncResult asyncResult, ref TYPE result);
	}
}
